public Order findOrderId(String idOrder, boolean retrieveAssociation){
	String wClause = " idOrder = '" + idOrder + "'";
	return singleWhere(wClause, retrieveAssociation);
}

public int insertOrder(Order order) throws Exception{
	int nextIdOrder = GetMax.getMaxId("Select max(idOrder) from [order]");
	nextIdOrder = nextIdOrder + 1;
	System.out.println("next idOrder = " + nextIdOrder);

	int rc = -1;

	String query = "INSERT INTO [Order](idOrder, idOffer, createdDate,"+ 
		" paymentDeadline, statusOrder) VALUES('" +
		nextIdOrder + "','" +
		order.getOffer().getIdOffer() + "','" +
		order.getCreatedDate() + "','" +
		order.getPaymentDeadline() + "','" +
		order.getStatusOrder() + "')";

	System.out.println("insert : " + query);
	try {
		Statement stmt = con.createStatement();
		stmt.setQueryTimeout(5);
		rc = stmt.executeUpdate(query);
		stmt.close();
	}
	catch (SQLException ex){
		System.out.println("Order not created");
		throw new Exception("Order is not inserted correctly");
	}
return rc;
}


public int updateOrder(Order order){
	Order orderObj = order;
	int rc =-1;

	String query = "UPDATE [order] WHERE idOrder = '" + orderObj.getIdOrder() +  "' SET " +
		"createdDate ='" + orderObj.getCreatedDate() + "', " +
		"paymentDeadline ='" + orderObj.getPaymentDeadline() + "', " +
		"statusOrder ='" + orderObj.getStatusOrder() + "'";
	System.out.println("Update query:" + query);

	try {
	    Statement stmt = con.createStatement();
	    stmt.setQueryTimeout(5);
	    rc = stmt.executeUpdate(query);

	    stmt.close();
	}
	catch(Exception ex){
	    System.out.println("Update exception in order db: "+ex);
	}
	return(rc);
}


public int deleteOrder(String idOrder){
	int rc=-1;

	String query = "DELETE FROM [order] WHERE idOrder = '" +
        idOrder + "'";
	System.out.println(query);
	try {
	    Statement stmt = con.createStatement();
	    stmt.setQueryTimeout(5);
	    rc = stmt.executeUpdate(query);
	    stmt.close();
	}
	catch(Exception ex){
	    System.out.println("Delete exception in order db: "+ex);
	}
	return(rc);
}
